home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Reversi.dxr / playing cards_55_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.9 KB  |  148 lines

  1. property spriteNum, row, location
  2. global tableau, stock, currentsel, points, vanish, topRow, midRow, botRow
  3.  
  4. on beginSprite me
  5.   location = sprite(spriteNum).loc
  6.   row = determinerow()
  7.   sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  8.   stock.cards.deleteAt(1)
  9.   tableau.addProp(row, new(script("card pile")))
  10.   tableau[row].addCard(spriteNum)
  11.   sprite(spriteNum).visible = 1
  12. end
  13.  
  14. on determinerow
  15.   if spriteNum = 11 then
  16.     return #one
  17.   else
  18.     if spriteNum = 13 then
  19.       return #two
  20.     else
  21.       if spriteNum = 15 then
  22.         return #three
  23.       else
  24.         if spriteNum = 17 then
  25.           return #four
  26.         else
  27.           if spriteNum = 18 then
  28.             return #five
  29.           else
  30.             if spriteNum = 20 then
  31.               return #six
  32.             else
  33.               if spriteNum = 22 then
  34.                 return #seven
  35.               else
  36.                 if spriteNum = 24 then
  37.                   return #eight
  38.                 else
  39.                   if spriteNum = 25 then
  40.                     return #nine
  41.                   else
  42.                     if spriteNum = 27 then
  43.                       return #ten
  44.                     else
  45.                       if spriteNum = 29 then
  46.                         return #eleven
  47.                       else
  48.                         if spriteNum = 31 then
  49.                           return #twelve
  50.                         end if
  51.                       end if
  52.                     end if
  53.                   end if
  54.                 end if
  55.               end if
  56.             end if
  57.           end if
  58.         end if
  59.       end if
  60.     end if
  61.   end if
  62. end
  63.  
  64. on mouseDown me
  65.   if tableau[row].getcardcount() > 0 then
  66.     if currentsel.count() < 2 then
  67.       if not currentsel.findPos(spriteNum) then
  68.         puppetSound(3, member("pick card", "100GPak Generic SFX"))
  69.         currentsel.add(spriteNum)
  70.         sprite(spriteNum).member = member(sprite(spriteNum).member.name & "_black", "playing cards")
  71.       end if
  72.       if currentsel.count() = 2 then
  73.         currentsel.sort()
  74.         checkCardValues()
  75.       end if
  76.     end if
  77.   end if
  78. end
  79.  
  80. on checkCardValues me
  81.   if (sprite(currentsel[2]).loc - sprite(currentsel[1]).loc) = point(120, 0) then
  82.     if tableau[sprite(currentsel[1]).row].getlastcard().rank = tableau[sprite(currentsel[2]).row].getlastcard().rank then
  83.       if getRow(currentsel[2]).count() > 3 then
  84.         vanish = timeout("vanish").new(200, #vanishit, sprite(currentsel[2]))
  85.       else
  86.         vanish = timeout("vanish").new(200, #vaniall, sprite(currentsel[2]))
  87.       end if
  88.       points = points + 40
  89.       checkwin()
  90.     else
  91.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  92.       vanish = timeout("vanish2").new(200, #nogo)
  93.     end if
  94.   else
  95.     puppetSound(3, member("drop card", "100GPak Generic SFX"))
  96.     vanish = timeout("vanish3").new(200, #nogo)
  97.   end if
  98. end
  99.  
  100. on vanishit me
  101.   vanish.forget()
  102.   puppetSound(3, member("pick card", "100GPak Generic SFX"))
  103.   sprite(currentsel[1]).member = member(chars(sprite(currentsel[1]).member.name, 1, sprite(currentsel[1]).member.name.length - 6), "playing cards")
  104.   sprite(spriteNum).member = member("empty", "playing cards")
  105.   sprite(spriteNum).visible = 0
  106.   sprite(spriteNum - 1).member = member("empty", "playing cards")
  107.   sprite(spriteNum - 1).visible = 0
  108.   repeat with i = 1 to tableau[sprite(currentsel[2]).row].cards.count
  109.     sprite(32).member = member(tableau[sprite(currentsel[2]).row].cards[1].membername, "playing cards")
  110.     updateStage()
  111.   end repeat
  112.   currentsel.sort()
  113.   if getRow(currentsel[2]).findPos(currentsel[2]) > 2 then
  114.     repeat with i = getRow(currentsel[2]).count() down to getRow(currentsel[2]).findPos(currentsel[2])
  115.       sprite(getRow(currentsel[2])[i]).loc = sprite(getRow(currentsel[2])[i - 2]).location
  116.       updateStage()
  117.     end repeat
  118.   end if
  119.   getRow(currentsel[2]).deleteOne(currentsel[2])
  120.   getRow(currentsel[2]).deleteOne(currentsel[2] - 1)
  121.   tableau.deleteProp(sprite(currentsel[2]).row)
  122.   currentsel.deleteAll()
  123.   checkwin()
  124. end
  125.  
  126. on vaniall me
  127.   vanish.forget()
  128.   puppetSound(3, member("pick card", "100GPak Generic SFX"))
  129.   sprite(currentsel[1]).member = member("empty", "playing cards")
  130.   sprite(spriteNum).member = member("empty", "playing cards")
  131.   sprite(spriteNum - 1).member = member("empty", "playing cards")
  132.   repeat with i = 1 to tableau[sprite(currentsel[2]).row].cards.count
  133.     sprite(32).member = member(tableau[sprite(currentsel[2]).row].cards[1].membername, "playing cards")
  134.     updateStage()
  135.   end repeat
  136.   repeat with i = 1 to tableau[sprite(currentsel[1]).row].cards.count
  137.     sprite(32).member = member(tableau[sprite(currentsel[1]).row].cards[1].membername, "playing cards")
  138.     updateStage()
  139.   end repeat
  140.   getRow(currentsel[2]).deleteOne(currentsel[2])
  141.   getRow(currentsel[2]).deleteOne(currentsel[2] - 1)
  142.   tableau[sprite(currentsel[1]).row].cards.deleteAll()
  143.   tableau[sprite(currentsel[2]).row].cards.deleteAll()
  144.   currentsel.deleteAll()
  145.   points = points + 10
  146.   checkwin()
  147. end
  148.